// JavaScript Document

function table_tr_color(){
	$(".table_list tr:odd").addClass("tr_odd");
	$(".table_list tr:even").addClass("tr_even");
	$(".table_list tr:gt(0)").hover(function(){
		$(this).addClass("tr_cur");
	},function(){
		$(this).removeClass("tr_cur");
		$(".table_list tr:odd").addClass("tr_odd");
	    $(".table_list tr:even").addClass("tr_even");
	});
};

$(function(){
	$("th").click(function(){//在rt_list.js中增加保存排序字段到cookie的操作
		var tosort = $(this).attr('class');
		var exp=$(this)[0].exp;
		if(exp && exp.indexOf("<a")==0 && exp.indexOf("</a>")>0){//如果th是<a href></a>格式的，去标签内的内容
			exp= exp.substring(exp.indexOf(">")+1);
			exp= exp.substring(0,exp.indexOf("</a>"));
		}
		if(exp.substr(0,1)=="{"&&exp.substr(exp.length-1)=="}"){//如果是以"{"开头，以"}"结尾，才进行排序
		    var fieldName=exp.replace("{","");
		    fieldName=fieldName.replace("}","");
		    $("#sortField").attr("title",fieldName);
		    $("#sortType").attr("title"," desc");
			if(tosort=="up"){
				$(this).removeClass();
				$(this).addClass("down");
			}else if(tosort=="down"){
				$(this).removeClass();
				$(this).addClass("up");
				$("#sortType").attr("title"," asc");
			}else{
				$("th").removeClass();
				$(this).addClass("down");
			}
			$(this).attr('onFocus','none');
		}
	});
});

function addSearchRow(maxNum){
	var rowHeight = 30;
	if(maxNum==undefined || maxNum<1 || maxNum>10){
		maxNum = 8;
	}
	if($(".table_search tr").length >= maxNum){
		dialogOpen('注意',320,150,'dialog/alert_max.html'); //dialogOpen(tt,w,h,src);
	}else{
		$(".table_search").animate({
			height: $(".table_search").height()+rowHeight
		},200,function(){
			$(".table_search tbody").html($(".table_search tbody").html()+$(".table_search tbody tr:last").html());
			if(typeof(dataListCttHeight)=="function"){
				dataListCttHeight(rowHeight);
			};
		});
	}
};
function deleteSearchRow(){
	table_tr_color();
	var rowHeight = 30;
	if($(".table_search tbody tr").length < 2){
		dialogOpen('注意',320,150,'dialog/alert_min.html'); //dialogOpen(tt,w,h,src);
	}else{
		$(".table_search tbody tr:last").remove();
		$(".table_search").animate({
			height: $(".table_search").height()-rowHeight
		},200,function(){
			if(typeof(dataListCttHeight)=="function"){
				dataListCttHeight(rowHeight);
			};
		});
	}
};